<?php
// +----------------------------------------------------------------------
// | Author: wyd 2025/10/26
// | DESC: 
// +----------------------------------------------------------------------

declare (strict_types=1);


require_once 'vendor/autoload.php';

use Illuminate\Database\Query\Builder;
use Study\laravel\db\DbManager1;

//use Illuminate\Database\Capsule\Manager as DbManager;
//
//$capsule = new DbManager();
//
//$capsule->addConnection([
//    'driver' => 'mysql',
//    'host' => '192.168.30.201',
//    'database' => 'crmeb',
//    'username' => 'wyd',
//    'password' => '123456',
//    'charset' => 'utf8',
//    'collation' => 'utf8_unicode_ci',
//    'prefix' => 'eb_',
//]);
//
//// 设置全局访问
//$capsule->setAsGlobal();
//
//// 启动Eloquent
//$capsule->bootEloquent();
//
////通过静态方法直接查询
//$res = $capsule::table('user')->first();
//var_dump($res);

/********************************************************************************************************************/
//2、封装后调用
//$manager = new DbManager();
//$res = $manager::table('user')->first();
//var_dump($res->phone);

//3、多数据库切换
//2、封装后调用
$manager = new \Study\laravel\db\DbManager();
$res = $manager->table('user')->first();
var_dump($res->phone);

//connection 这里只是调用，添加是通过config判断早已添加进去了
$res1 = $manager->connection('test')->table('user')->first();
var_dump($res1->phone);

$res2 = $manager->table('user')->first();
var_dump($res2->phone);